export default function useRendererListen(
  responseName: string,
  unique: string | null,
  callback: (info: any) => void
) {
  const removeListener = window.electron.ipcRenderer.on(
    'main-to-renderer',
    (_, { name, id, ...otherData }) => {
      if (name === responseName) {
        ;((unique && unique === id) || !unique) && callback(otherData)
      }

      removeListener()
    }
  )
}
